<?php

class SQL
{
	 public static function error($p_query)
	 {	
		 if (mysql_errno()) 
		 { 
			 $error = "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$p_query\n<br>";
			 trigger_error($error, E_USER_ERROR);	
         } 
	 }
	 
	 public static function execute($p_query)
	 {
		 if (!mysql_query($p_query))
		 {
			self::error($p_query);
			 return false;
		 }
		 else 
		 {
			 return true;
		 }
	 }
	 
	 public static function num_rows($p_query)
	 {
		 $result=mysql_query($p_query);
		 
		 if (!$result)
		 {
			 self::error($p_query);
			 return false;
		 }
		 else 
		 {
			 return mysql_num_rows($result);
		 }
	 }
	 
	  public static function select($p_query)
	 {
		 $result=mysql_query($p_query);
		 
		 if (!$result)
		 {
			 self::error($p_query);
			 return false;
		 }
		 else 
		 {
			 $data=array();
			 
			 while ($row=mysql_fetch_array($result))
			 {
				 $data[]=$row;
			 }
			 return $data;
		 }
	 }

}